import request from '@/utils/request'

export default {
  getAllCart() {
    return request({
      url: '/cart/all',
      method: 'get'
    })
  },
  addCart(cart) {
    return request({
      url: '/cart',
      method: 'post',
      data: cart
    })
  },
  getCartById(id) {
    return request({
      url: `/cart/${id}`,
      method: 'get'
    })
  },
  deleteCartById(id) {
    return request({
      url: `/cart/${id}`,
      method: 'delete'
    })
  },
  getUserMoneyByUsername(username) {
    return request({
      url: 'cart/money',
      method: 'get',
      params: { username }
    })
  },
  updateCart(cart) {
    return request({
      url: '/cart',
      method: 'put',
      data: cart
    })
  }
}
